package com.gujh.security.model;

import lombok.Data;

import java.io.Serializable;

@Data
public class Res<DATA> implements Serializable {

    private Integer code;

    private String message;

    private DATA data;

    public static <DATA> Res<DATA> success(DATA data) {
        Res<DATA> result = new Res<>();
        result.setData(data);
        result.setCode(200);
        result.setMessage("success");
        return result;
    }

    public static <DATA> Res<DATA> success(DATA data, String message) {
        Res<DATA> result = new Res<>();
        result.setCode(200);
        result.setData(data);
        result.setMessage(message);
        return result;
    }

    public static Res<Void> fail(String message) {
        Res<Void> result = new Res<>();
        result.setCode(500);
        result.setMessage(message);
        return result;
    }
}
